<?php

namespace JJ;

class Route
{
    static function to()
    {
        $args = explode('/', parse_url($_SERVER['REQUEST_URI'])['path']);
        $dir  = './';
        $cls  = '\\';
        foreach ($args as $i => $arg) {
            var_dump($arg);
            if ($i < 2) {
                continue;
            }
            $arg = str_replace('_', '', ucwords($arg, '_'));
            if (is_dir($dir)) {
                echo $dir;
                $dir .= $arg . '/';
                $cls .= $arg . '\\';
            } else {
                $cls .= 'C\\' . $arg;
                echo $cls;
                $a   = $arg[$i + 1];
                (new $cls())->$a();
                break;
            }
        }
    }

    static function route_m()
    {

    }

    static function route_c()
    {

    }

    static function route_a()
    {

    }
}
